package com.myorg.search.condition;

public class OrCondition extends SearchCondition {
	private SearchCondition left = null;
	private SearchCondition right = null;

	public OrCondition(SearchCondition left, SearchCondition right) {
		this.left = left;
		this.right = right;
	}

	@Override
	public String matchAndSummarize(String s) {
		String leftSummary = left == null ? null : left.matchAndSummarize(s);
		if (leftSummary != null) {
			return leftSummary;
		}

		String rightSummary = right == null ? null : right.matchAndSummarize(s);
		if (rightSummary != null) {
			return rightSummary;
		}

		return null;
	}
}